const {Client, logger, Variables} = require('camunda-external-task-client-js');
// import { Client, logger, Variables } from 'camunda-external-task-client-js';
// const { Client } = require("camunda-external-task-handler-js");
const open = require('open')

const config = {baseUrl: 'http://localhost:8082/engine-rest', use: logger, asyncResponseTimeout: 10000};
const client = new Client(config)

client.subscribe('pay', {processDefinitionKey: "Process_shopping"},
    async function ({task, taskService}) {
        const size = task.variables.get('size');
        const count = task.variables.get('count');

        console.log(`顾客下单尺寸：${size},数量：${count}`)
        const processVariables = new Variables.set("toWhere", "上海");

        try {
            await taskService.complete(task, processVariables);
            console.log('I completed my task successfully')
        } catch (e) {
            console.error(`Failed completing my task, ${e}`)
        }
    }
);